//package com.qcu.config;
//
//
//import com.qcu.util.JwtUtil;
//import com.qcu.util.ThreadLocalUtil;
//import io.lettuce.core.RedisClient;
//import io.lettuce.core.api.StatefulRedisConnection;
//import io.lettuce.core.api.sync.RedisCommands;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpSession;
//import javax.websocket.HandshakeResponse;
//import javax.websocket.Session;
//import javax.websocket.server.HandshakeRequest;
//import javax.websocket.server.ServerEndpointConfig;
//import java.util.List;
//import java.util.Map;
//
///**
// * 获取HttpSession，这样的话，ChatEndpoint类就能操作HttpSession
// */
//
//public class GetHttpSessionConfig extends ServerEndpointConfig.Configurator {
//
//    @Override
//    public void modifyHandshake(ServerEndpointConfig serverEndpointConfig, HandshakeRequest request, HandshakeResponse response) {
//
////        RedisClient redisClient = RedisClient.create("redis://localhost:6379");
////        StatefulRedisConnection<String, String> connection = redisClient.connect();
////        RedisCommands<String, String> commands = connection.sync();
////
////        String value = commands.get("currentUM");
//
////        List<String> token = request.getParameterMap().get("token");
////        String s = token.get(0);
////        Map<String, Object> map = JwtUtil.parseToken(s);
////        String o = (String) map.get("username");
//        // 获取 HttpSession 对象
//        HttpSession httpSession = (HttpSession) request.getHttpSession();
////        httpSession.setAttribute("currentUser",value);
////        ThreadLocalUtil.set(httpSession);
//        // 将 httpSession 对象保存起来，存到 ServerEndpointConfig 对象中
//        // 在 ChatEndpoint 类的 onOpen 方法就能通过 EndpointConfig 对象获取在这里存入的数据
//        serverEndpointConfig.getUserProperties().put(HttpSession.class.getName(), httpSession);
////        connection.close();
//    }
//
//}
